package com.family.floor.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.family.floor.entity.LeadingHousingEntity;
import com.family.floor.service.LeadingHousingService;
import com.family.common.utils.PageUtils;
import com.family.common.utils.R;



/**
 * 
 *
 * @author Qzy
 * @email 2434785870@qq.com
 * @date 2021-09-17 09:10:24
 */
@RestController
@CrossOrigin
@RequestMapping("floor/leadinghousing")
public class LeadingHousingController {
    @Autowired
    private LeadingHousingService leadingHousingService;
    /**
     * 查询所有的房源
     */
    @RequestMapping("all")
    public R findAll(){
        List<LeadingHousingEntity> list = leadingHousingService.list();
        return R.ok().setData(list);
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = leadingHousingService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		LeadingHousingEntity leadingHousing = leadingHousingService.getById(id);

        return R.ok().put("leadingHousing", leadingHousing);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LeadingHousingEntity leadingHousing){
		leadingHousingService.save(leadingHousing);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LeadingHousingEntity leadingHousing){
		leadingHousingService.updateById(leadingHousing);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		leadingHousingService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
